package com.nmsl.registration.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.registration.domain.skxPhysicalInfo;
import com.nmsl.registration.service.IskxPhysicalInfoService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 体格信息Controller
 * 
 * @author skx
 * @date 2025-02-24
 */
@RestController
@RequestMapping("/skx/info")
public class skxPhysicalInfoController extends BaseController
{
    @Autowired
    private IskxPhysicalInfoService skxPhysicalInfoService;

    /**
     * 查询体格信息列表
     */
    @PreAuthorize("@ss.hasPermi('skx:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(skxPhysicalInfo skxPhysicalInfo)
    {
        startPage();
        List<skxPhysicalInfo> list = skxPhysicalInfoService.selectskxPhysicalInfoList(skxPhysicalInfo);
        return getDataTable(list);
    }

    /**
     * 导出体格信息列表
     */
    @PreAuthorize("@ss.hasPermi('skx:info:export')")
    @Log(title = "体格信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, skxPhysicalInfo skxPhysicalInfo)
    {
        List<skxPhysicalInfo> list = skxPhysicalInfoService.selectskxPhysicalInfoList(skxPhysicalInfo);
        ExcelUtil<skxPhysicalInfo> util = new ExcelUtil<skxPhysicalInfo>(skxPhysicalInfo.class);
        util.exportExcel(response, list, "体格信息数据");
    }

    /**
     * 获取体格信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('skx:info:query')")
    @GetMapping(value = "/{visitRecordId}")
    public AjaxResult getInfo(@PathVariable("visitRecordId") Long visitRecordId)
    {
        return success(skxPhysicalInfoService.selectskxPhysicalInfoByPhysicalInfoId(visitRecordId));
    }

    /**
     * 新增体格信息
     */
    @PreAuthorize("@ss.hasPermi('skx:info:add')")
    @Log(title = "体格信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody skxPhysicalInfo skxPhysicalInfo)
    {
        return toAjax(skxPhysicalInfoService.insertskxPhysicalInfo(skxPhysicalInfo));
    }

    /**
     * 修改体格信息
     */
    @PreAuthorize("@ss.hasPermi('skx:info:edit')")
    @Log(title = "体格信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody skxPhysicalInfo skxPhysicalInfo)
    {
        return toAjax(skxPhysicalInfoService.updateskxPhysicalInfo(skxPhysicalInfo));
    }

    /**
     * 删除体格信息
     */
    @PreAuthorize("@ss.hasPermi('skx:info:remove')")
    @Log(title = "体格信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{physicalInfoIds}")
    public AjaxResult remove(@PathVariable Long[] physicalInfoIds)
    {
        return toAjax(skxPhysicalInfoService.deleteskxPhysicalInfoByPhysicalInfoIds(physicalInfoIds));
    }
}
